<script type="text/javascript">
$(function(){
    //親カテゴリーの変更時のイベント
    $('select#SearchconditionArticleCategoryCode')
    	.change(function(){    // chengeイベントにイベントハンドラをバインド
    		
        	//選択された親カテゴリ取得
	        var selected =this.value;
	        
	        $("select#SearchconditionArticleKocategoryCode option").remove();
	        
	        //空白行を追加
			$("select#SearchconditionArticleKocategoryCode").append('<option value=""></option>');
			
	        if(!(selected=='')){

				//子カテゴリを取得
	        	var koselected = $.cookie('kocategorycode');
				
		        //カテゴリを取得
				$.ajaxSetup({ ifModified: true , cache: false}); 
				$.getJSON(
			        '/ajax/getKocategory/',
			        { CategoryCode:selected},
				    function(json, status) {
			        	
				        $.each(json.CategoryList.Categories,function(i,items){
					        //カテゴリを追加
	        				if (koselected == items.Code){
								$("select#SearchconditionArticleKocategoryCode").append('<option value="'.concat(items.Code).concat( '" selected="selected">').concat(items.Name).concat('</option>'));
	        				}
					        else{
								$("select#SearchconditionArticleKocategoryCode").append('<option value="'.concat(items.Code).concat( '">').concat(items.Name).concat('</option>'));
					        }
				        });
				    }
		        );
	        }
	    })
	    .change();

    //カテゴリーの変更時のイベント
    $('select#SearchconditionArticleKocategoryCode')
    	.change(function(){    // chengeイベントにイベントハンドラをバインド
        	//選択された親カテゴリ取得
		var options = { path: '/'};
    	var selected =this.value;
	        if(!(selected=='')){
	        	$.cookie('kocategorycode',selected,options);
	        }
	        else{
	        	$.cookie('kocategorycode',null,options);
	        }
    });
    
});
</script>

<?php echo $html->image('searcharticle.jpg', array('width' => 340, 'height' => 40)); ?><br>
<?php echo $form->create(null, array('controller' => 'main','action' => 'search')); ?>
<b>親カテゴリ</b><br>
<?php 
	$category = array("01" => 'フード・ドリンク',"02" => 'ブランド',"03" => 'ファッション',
	"04" => 'AV・デジモノ',"05" => '家電',"06" => '美容・コスメ',"07" => 'ダイエット・健康',"08" => '生活雑貨',
	"09" => 'ホビー・エトセトラ',"10" => 'スポーツ・レジャー');
	$options = array('empty' => false); 
	echo $form->select('Searchcondition.article_category_code',$category,null,$options);
	//echo $form->select('Searchcondition.article_category_code',$category);
?>
<br>
<b>カテゴリ</b><br>
<?php 
	$category = array();
	echo $form->select('Searchcondition.article_kocategory_code',$category);
?>
<br>
<b>商品ID</b><br>
<?php echo $form->text('Searchcondition.article_id')?>
<br>
<b>キーワード</b><br>
<?php echo $form->text('Searchcondition.words',array("size" => 50));?>
<br>
<table width = "200" border="0" align="center" >
<tr VALIGN="middle"  >
	<td>
	<?php echo $html->image('icon-new.gif'); ?>
	</td>
	<td>
	<?php echo $html->image('icon-salable.gif'); ?>
	</td>
	<td>
	<?php echo $html->image('icon-ships-sameday.gif'); ?>
	</td>
	<td>
	<?php echo $html->image('icon-configured.gif'); ?>
	</td>
	<td>
	<?php echo $html->image('icon-free-shipping.gif'); ?>
	</td>
</tr>
<tr VALIGN="middle" >
	<td>
	<?php echo $form->checkbox('Searchcondition.newly');?>
	</td>
	<td>
	<?php echo $form->checkbox('Searchcondition.salable');?>
	</td>
	<td>
	<?php echo $form->checkbox('Searchcondition.delivery_sameday');?>
	</td>
	<td>
	<?php echo $form->checkbox('Searchcondition.has_shop_price');?>
	</td>
	<td>
	<?php echo $form->checkbox('Searchcondition.free_shipping');?>
	</td>
</tr>
</table>
<table width = "300" border="0" align="left" >
<tr VALIGN="middle"  >
	<th WIDTH="100" nowrap>在庫状況</th>
	<th WIDTH="100" nowrap>在庫の有無</th>
</tr>
<tr VALIGN="middle"  >
	<td nowrap>
<?php 
//$stock = array("1" => '在庫切れ',"2" => '在庫わずか',"3" => '在庫あり',"4" => '在庫豊富');
	$stock = array("1" => '在庫わずか',"2" => '在庫あり',"3" => '在庫豊富');
	echo $form->select('Searchcondition.stock_status',$stock);
?></td>
	<td nowrap>
<?php 
	$exists = array("1" => '在庫あり商品のみ',"2" => '在庫なし商品のみ');
	echo $form->select('Searchcondition.exists_stock',$exists);
?></td>
</tr>
</table>
<br><br><br><br>
<b>標準利益価格</b><br>
<?php echo $form->text('Searchcondition.default_profit_price_from',array("size" => 7))?>
<?php echo ' ～ '. $form->text('Searchcondition.default_profit_price_to',array("size" => 7))?>
<br>
<b>表示順</b><br>
<?php 
	$sort = array("newly" => '新着順',"sales" => '売上順',"word" => 'キーワード順',
	"profit_price_a" => '標準利益額昇順',"profit_price_d" => '標準利益額降順',
	"profit_rate_a" => '標準利益率昇順',"profit_rate_d" => '標準利益率降順',
	"recommendation_price_a" => '推奨販売価格昇順',"recommendation_price_d" => '推奨販売価格降順',
	"fixed_price_a" => '希望小売価格昇順',"fixed_price_d" => '希望小売価格降順');
echo $form->select('Searchcondition.sort_order',$sort);
?>
<br>
<b>表示件数</b><br>
<?php 
	$list_per = array("10" => '10',"30" => '30',"50" => '50',"70" => '70',"100" => '100');
echo $form->select('Searchcondition.list_per_page',$list_per);
?>


<div style="<?php $html->style('form_submit'); ?>">
<?php echo $form->submit('検索', array('div' => false)); ?></div>
<?php echo $form->end(null); ?>
